const studentModel = require('../dao/student.js');

module.exports={
    //学生列表
    async AccordingToStudents(){
        return await studentModel.ShowAllStudents();
    },
    //添加学生
    async Addstudents(name, age,gender,score,address,photo){
        return await studentModel.AddStudent(name, age,gender,score,address,photo);
    },
    //删除学生
    async Delstudents(studentId){
        return await studentModel.DelStudentsId({'_id':studentId});
    },
    //查询学生
    async detailStudents(studentId){
        return await studentModel.getStudentsId(studentId);
    },
     //修改学生
     async updataStudents({'_id':studentId},{name, age,gender,score,address}){
        return await studentModel.updStudentsId({'_id':studentId},{name, age,gender,score,address});
    },
    //分页
    async getAccessToPag({currentpage,pagesize}){
        //创建一个空对象
       let pagedata={};
       //当前页数
       pagedata.currentpage=currentpage;
        //每页显示的条数
       pagedata.pagesize=pagesize;
       //显示的数据
       pagedata.data=await studentModel.accessToPag({currentpage,pagesize});
        //总条数
       pagedata.totalInt=await studentModel.getsNumber();
       //总页数
       pagedata.totalSize=Math.ceil( pagedata.totalInt/pagesize);
       return pagedata
    },
}